# Maintainer: David Runge <dvzrv@archlinux.org>

_name=coverage-conditional-plugin
pkgname=python-coverage-conditional-plugin
pkgver=0.8.0
pkgrel=2
pkgdesc="Conditional coverage based on any rules you define"
arch=(any)
url="https://github.com/wemake-services/coverage-conditional-plugin"
license=(MIT)
depends=(python-coverage python-packaging)
makedepends=(python-build python-installer python-poetry-core python-wheel)
checkdepends=(python-pytest python-pytest-cov python-pytest-randomly)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha256sums=('e6564944a32ccc962f8c0000ac618efa5f5ff232cb9bcc677ce98546dfa61e6d')
b2sums=('23541918919ec5f6c6cf4db0aad02da27a4dab0dfc9595578aa29db2b621b1de391ae20bfb1f1efd166f6514e7dcdca6b2cf231f9639bf619ae4521d9ac420df')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location, as importlib is used
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  # ignore integration tests
  pytest -vv -c /dev/null --ignore tests/test_integration.py
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
}
